package com.lyl.syt.common.exception;/**
 * @author Mr.Luo
 * @date 2022-04-24 17:37
 */

import com.lyl.syt.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Mr.Luo
 * @date 2022-04-24 17:37
 * @desc 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<Boolean> error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(YyghException.class)
    public Result<Boolean> onYyghException(YyghException e){
        e.printStackTrace();
        return Result.build(e.getCode(), e.getMessage());
    }


}
